Concerns about Data:

Franchise vs individual establishment: The data is listed by individual establishment. For example, in the first 400 rows, there are 7 McDonalds (in PR).

Square footage: I double checked and didn’t find this. There is an Office Size Code column but it is empty.

Other Notes:

Data also contains the percent of businesses in each municipality that are in each 2-digit NAICS classification. I did not visualize those for eac

library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.0 ──
## ✓ ggplot2 3.3.2     ✓ purrr   0.3.4
## ✓ tibble  3.0.4     ✓ dplyr   1.0.2
## ✓ tidyr   1.1.2     ✓ stringr 1.4.0
## ✓ readr   1.4.0     ✓ forcats 0.5.0
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## x dplyr::filter() masks stats::filter()
## x dplyr::lag()    masks stats::lag()
library(tidylog)
## 
## Attaching package: 'tidylog'
## The following objects are masked from 'package:dplyr':
## 
##     add_count, add_tally, anti_join, count, distinct, distinct_all,
##     distinct_at, distinct_if, filter, filter_all, filter_at, filter_if,
##     full_join, group_by, group_by_all, group_by_at, group_by_if,
##     inner_join, left_join, mutate, mutate_all, mutate_at, mutate_if,
##     relocate, rename, rename_all, rename_at, rename_if, rename_with,
##     right_join, sample_frac, sample_n, select, select_all, select_at,
##     select_if, semi_join, slice, slice_head, slice_max, slice_min,
##     slice_sample, slice_tail, summarise, summarise_all, summarise_at,
##     summarise_if, summarize, summarize_all, summarize_at, summarize_if,
##     tally, top_frac, top_n, transmute, transmute_all, transmute_at,
##     transmute_if, ungroup
## The following objects are masked from 'package:tidyr':
## 
##     drop_na, fill, gather, pivot_longer, pivot_wider, replace_na,
##     spread, uncount
## The following object is masked from 'package:stats':
## 
##     filter
library(sf)
## Linking to GEOS 3.8.1, GDAL 3.1.1, PROJ 6.3.1
library(tmap)
 
bus_data <- read.csv("data_in_progress/nj_bus_mun.csv",
                     colClasses = c("SSN" = "character")) 

mun <- st_read("data_in_progress/mun_boundaries.geojson") %>%
  select(SSN) 
## Reading layer `mun_boundaries' from data source `/Users/gabemorrison/Documents/U_Chicago_Year_4/NJ-opioidenv/data_in_progress/mun_boundaries.geojson' using driver `GeoJSON'
## Simple feature collection with 565 features and 6 fields
## geometry type:  MULTIPOLYGON
## dimension:      XY
## bbox:           xmin: 193684.7 ymin: 34954.71 xmax: 657059.7 ymax: 919556.3
## projected CRS:  NAD83 / New Jersey (ftUS)
## select: dropped 5 variables (Place.Name, GNIS_NAME, GNIS, SQ_MILES, POP2010)
bus_data <- left_join(bus_data, mun) %>%
  st_as_sf
## Joining, by = "SSN"
## left_join: added one column (geometry)
##            > rows only in x     1
##            > rows only in y  (  1)
##            > matched rows     564
##            >                 =====
##            > rows total       565
col_names <- colnames(bus_data)
col_names <- col_names[-(1:2)]
col_names <- col_names[-97]

make_map <- function(col_name) {
  tm_shape(bus_data) + tm_fill(col = col_name, style = "jenks") + tm_borders(alpha = .15)
}
maps <- lapply(col_names, make_map)

Emp Size 18, 14, dif:

Takeaways: Generally small employment size near NYC; mean size increased slightly in rural areas, not a ton in urban NE and E.

maps[1]
## [[1]]
## Warning: The shape bus_data contains empty units.

maps[2]
## [[1]]
## Warning: The shape bus_data contains empty units.

maps[33]
## [[1]]
## Warning: The shape bus_data contains empty units.
## Some legend labels were too wide. These labels have been resized to 0.65, 0.65, 0.65. Increase legend.width (argument of tm_layout) to make the legend wider and therefore the labels larger.

maps[34]
## [[1]]
## Warning: The shape bus_data contains empty units.

maps[65]
## [[1]]
## Warning: The shape bus_data contains empty units.
## Variable(s) "pct_change_mean_emp_size" contains positive and negative values, so midpoint is set to 0. Set midpoint = NA to show the full spectrum of the color palette.
## Some legend labels were too wide. These labels have been resized to 0.62, 0.65, 0.65, 0.65, 0.65. Increase legend.width (argument of tm_layout) to make the legend wider and therefore the labels larger.

maps[66]
## [[1]]
## Warning: The shape bus_data contains empty units.
## Variable(s) "pct_change_med_emp_size" contains positive and negative values, so midpoint is set to 0. Set midpoint = NA to show the full spectrum of the color palette.
## Some legend labels were too wide. These labels have been resized to 0.59, 0.62, 0.65, 0.65, 0.65. Increase legend.width (argument of tm_layout) to make the legend wider and therefore the labels larger.

##Sales Volume:

Takeaways: Again relatively consistent patterns. Appears that sales volume was relatively consistent but went down in rural western side.

maps[3]
## [[1]]
## Some legend labels were too wide. These labels have been resized to 0.65, 0.65, 0.65, 0.60. Increase legend.width (argument of tm_layout) to make the legend wider and therefore the labels larger.

maps[4]
## [[1]]

maps[35]
## [[1]]
## Some legend labels were too wide. These labels have been resized to 0.65, 0.65, 0.60, 0.55. Increase legend.width (argument of tm_layout) to make the legend wider and therefore the labels larger.

maps[36]
## [[1]]
## Some legend labels were too wide. These labels have been resized to 0.65, 0.65. Increase legend.width (argument of tm_layout) to make the legend wider and therefore the labels larger.

maps[67]
## [[1]]
## Variable(s) "pct_change_mean_sales_vol" contains positive and negative values, so midpoint is set to 0. Set midpoint = NA to show the full spectrum of the color palette.
## Some legend labels were too wide. These labels have been resized to 0.59, 0.62, 0.65, 0.65, 0.65. Increase legend.width (argument of tm_layout) to make the legend wider and therefore the labels larger.

maps[68]
## [[1]]
## Variable(s) "pct_change_med_sales_vol" contains positive and negative values, so midpoint is set to 0. Set midpoint = NA to show the full spectrum of the color palette.
## Some legend labels were too wide. These labels have been resized to 0.59, 0.59, 0.59, 0.62, 0.65. Increase legend.width (argument of tm_layout) to make the legend wider and therefore the labels larger.

##Simpson Index Number of employees:

Relatively high diversity across the state. Not a lot of variability in the measures :(, so may not be great for modelling.

maps[5]
## [[1]]
## Legend labels were too wide. The labels have been resized to 0.65, 0.65, 0.65, 0.65, 0.65. Increase legend.width (argument of tm_layout) to make the legend wider and therefore the labels larger.

maps[37]
## [[1]]
## Some legend labels were too wide. These labels have been resized to 0.65, 0.65, 0.65, 0.65, 0.65. Increase legend.width (argument of tm_layout) to make the legend wider and therefore the labels larger.

maps[69]
## [[1]]
## Variable(s) "pct_change_simp_index_emp_size" contains positive and negative values, so midpoint is set to 0. Set midpoint = NA to show the full spectrum of the color palette.
## Some legend labels were too wide. These labels have been resized to 0.59, 0.59, 0.62, 0.65, 0.65. Increase legend.width (argument of tm_layout) to make the legend wider and therefore the labels larger.

##Business Counts:

Takeaway: Consistently more businesses where there are more people, even as those municipalities are smaller. These data don’t change a ton 2014-2018 (light yellow is close to no change).

maps[32]
## [[1]]
## Some legend labels were too wide. These labels have been resized to 0.65, 0.65, 0.60. Increase legend.width (argument of tm_layout) to make the legend wider and therefore the labels larger.

maps[64]
## [[1]]
## Some legend labels were too wide. These labels have been resized to 0.65, 0.65, 0.60. Increase legend.width (argument of tm_layout) to make the legend wider and therefore the labels larger.

maps[96]
## [[1]]
## Variable(s) "pct_change_all_bus" contains positive and negative values, so midpoint is set to 0. Set midpoint = NA to show the full spectrum of the color palette.
## Some legend labels were too wide. These labels have been resized to 0.59, 0.59, 0.62, 0.65, 0.65. Increase legend.width (argument of tm_layout) to make the legend wider and therefore the labels larger.

Using NAICS to identify urban:

Not terribly successful; may need raw counts rather than percents

NAICS 54- Professional, Scientific, and Technical Services:

maps[18]
## [[1]]
## Legend labels were too wide. The labels have been resized to 0.65, 0.65, 0.65, 0.65, 0.65. Increase legend.width (argument of tm_layout) to make the legend wider and therefore the labels larger.

maps[52]
## [[1]]
## Some legend labels were too wide. These labels have been resized to 0.65, 0.65, 0.65, 0.65, 0.65. Increase legend.width (argument of tm_layout) to make the legend wider and therefore the labels larger.

maps[84]
## [[1]]
## Variable(s) "pct_change_pct_naics_2_54" contains positive and negative values, so midpoint is set to 0. Set midpoint = NA to show the full spectrum of the color palette.
## Some legend labels were too wide. These labels have been resized to 0.59, 0.62, 0.65, 0.65, 0.65. Increase legend.width (argument of tm_layout) to make the legend wider and therefore the labels larger.

#NAICS 55- Management of Companies and Enterprises:

maps[21]
## [[1]]
## Legend labels were too wide. The labels have been resized to 0.65, 0.65, 0.65, 0.65, 0.65. Increase legend.width (argument of tm_layout) to make the legend wider and therefore the labels larger.

maps[53]
## [[1]]
## Some legend labels were too wide. These labels have been resized to 0.55, 0.55, 0.55, 0.55, 0.55. Increase legend.width (argument of tm_layout) to make the legend wider and therefore the labels larger.

maps[85]
## [[1]]
## Variable(s) "pct_change_pct_naics_2_55" contains positive and negative values, so midpoint is set to 0. Set midpoint = NA to show the full spectrum of the color palette.
## Some legend labels were too wide. These labels have been resized to 0.65, 0.65, 0.65. Increase legend.width (argument of tm_layout) to make the legend wider and therefore the labels larger.

#NAICS 71- Arts, Entertainment, and Recreation:

maps[23]
## [[1]]
## Warning: The shape bus_data contains empty units.
## Legend labels were too wide. The labels have been resized to 0.65, 0.65, 0.65, 0.65, 0.65. Increase legend.width (argument of tm_layout) to make the legend wider and therefore the labels larger.

maps[57]
## [[1]]
## Warning: The shape bus_data contains empty units.
## Some legend labels were too wide. These labels have been resized to 0.65, 0.65, 0.65, 0.65, 0.65. Increase legend.width (argument of tm_layout) to make the legend wider and therefore the labels larger.

maps[89]
## [[1]]
## Warning: The shape bus_data contains empty units.
## Variable(s) "pct_change_pct_naics_2_71" contains positive and negative values, so midpoint is set to 0. Set midpoint = NA to show the full spectrum of the color palette.
## Some legend labels were too wide. These labels have been resized to 0.65, 0.65, 0.65. Increase legend.width (argument of tm_layout) to make the legend wider and therefore the labels larger.